package com.shujia.day18;

/*
    中断线程：
        public final void stop()
        public void interrupt()

    java所有的线程要想变成运行状态，必须经过抢cpu执行权

 */
class MyThread6 extends Thread{
    @Override
    public void run() {
        System.out.println("胡海祥准备睡觉了....睡足10秒钟");
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("睡醒了，继续敲代码！！！");
    }
}

public class ThreadDemo6 {
    public static void main(String[] args) {
        MyThread6 t1 = new MyThread6();
        t1.start();

        try {
            Thread.sleep(5000);
//            t1.stop();
            t1.interrupt();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
